package com.gxuwz.prrs.service.impl;

import com.google.gson.reflect.TypeToken;
import com.gxuwz.prrs.bean.CheckRecord;
import com.gxuwz.prrs.bean.CommonResponse;
import com.gxuwz.prrs.bean.Page;
import com.gxuwz.prrs.service.BaseService;
import com.gxuwz.prrs.utils.RequestUtils;
import okhttp3.FormBody;

import java.lang.reflect.Type;

/**
 * @author 张钧
 * @Description
 * @create 2023-05-24 上午 11:22
 */
public class CheckRecordServiceImpl implements BaseService<CheckRecord, Page<CheckRecord>> {

	@Override
	public Page<CheckRecord> page(Page<CheckRecord> page) {
		return null;
	}

	public Boolean check(CheckRecord checkRecord) {
		Long pianoRoomId = checkRecord.getPianoRoomId();
		String status = checkRecord.getStatus();
		FormBody.Builder builder = new FormBody.Builder();
		builder.add("pianoRoomId", String.valueOf(pianoRoomId));
		builder.add("status",status);
		String url = "/appointment/check";
		return getaBoolean(builder, url);
	}

	public static Boolean getaBoolean(FormBody.Builder builder, String url) {
		Type type = new TypeToken<CommonResponse<Boolean>>() {
		}.getType();
		CommonResponse<Boolean> s = RequestUtils.postRequest(url, builder.build(), type);
		if (s != null) {
			return s.getData();
		}
		return false;
	}
}
